package com.ruoyi.boat.controller;

import java.util.List;

import com.ruoyi.boat.aop.AvoidDuplicate;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.boat.domain.AdcpData;
import com.ruoyi.boat.service.IAdcpDataService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ADCP数据Controller
 *
 * @author ruoyi
 * @date 2023-08-09
 */
@Controller
@RequestMapping("/boat/adcpData")
public class AdcpDataController extends BaseController {
    private String prefix = "boat/adcpData";

    @Autowired
    private IAdcpDataService adcpDataService;

    @RequiresPermissions("boat:adcpData:view")
    @GetMapping()
    public String adcpData() {
        return prefix + "/adcpData";
    }

    /**
     * 查询ADCP数据列表
     */
    @RequiresPermissions("boat:adcpData:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AdcpData adcpData) {
        startPage();
        List<AdcpData> list = adcpDataService.selectAdcpDataList(adcpData);
        return getDataTable(list);
    }

    /**
     * 导出ADCP数据列表
     */
    @RequiresPermissions("boat:adcpData:export")
    @Log(title = "ADCP数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AvoidDuplicate
    @ResponseBody
    public AjaxResult export(AdcpData adcpData) {
        List<AdcpData> list = adcpDataService.selectAdcpDataList(adcpData);
        ExcelUtil<AdcpData> util = new ExcelUtil<AdcpData>(AdcpData.class);
        return util.exportExcel(list, "ADCP数据");
    }

    /**
     * 新增ADCP数据
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存ADCP数据
     */
    @RequiresPermissions("boat:adcpData:add")
    @Log(title = "ADCP数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AdcpData adcpData) {
        return toAjax(adcpDataService.insertAdcpData(adcpData));
    }

    /**
     * 修改ADCP数据
     */
    @RequiresPermissions("boat:adcpData:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        AdcpData adcpData = adcpDataService.selectAdcpDataById(id);
        mmap.put("adcpData", adcpData);
        return prefix + "/edit";
    }

    /**
     * 修改保存ADCP数据
     */
    @RequiresPermissions("boat:adcpData:edit")
    @Log(title = "ADCP数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AdcpData adcpData) {
        return toAjax(adcpDataService.updateAdcpData(adcpData));
    }

    /**
     * 删除ADCP数据
     */
    @RequiresPermissions("boat:adcpData:remove")
    @Log(title = "ADCP数据", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(adcpDataService.deleteAdcpDataByIds(ids));
    }
}
